#ifndef _L2_STRUC_H
#define _L2_STRUC_H

#include "input_struc.h"
#include "target_struc.h"
#include "hdf.h"
#include "HY1C_out.h"

typedef struct l2_struct {
    int32_t   sensorID;
    int32_t   length;
    int32_t   npix;
    int32_t   nbands;
    int32_t   nbandsir;
    int32_t   nscans;
    int32_t  *bindx;
    int32_t   ndets;
    int32_t   iscan;
    int32_t   ipix;
    int32_t   detnum;
    int32_t   mside;
    int32_t  *nobs;
    double fsol;
    float  tilt;
    char   *data;
    int32_t   *year;
    int32_t   *day;
    int32_t   *msec;
    float  *lon;
    float  *lat;
    float  *solz;
    float  *sola;
    float  *senz;
    float  *sena;
    float  *Lt;
    float  *Lt_theroy;
    float  *Lt_unc;
    int32_t   *aermodmin;
    int32_t   *aermodmax;
    float  *aerratio;
    float  *eps;
    float  *taua;
    float  *TLg;
    float  *La;
    float  *Lw;
    float  *nLw;
    float  *nLw_unc;
    float  *Rrs;
    float  *Rrs_unc;
    float  *brdf;
    float  *a;
    float  *bb;
    float  *chl;
    int32_t   *num_iter;

    /* These are just pointers to data in L1 record */
    int32_t   *pixnum;
    float  *Ltir;
    float  *Bt;
    float  *rhof;
    float  *tLf;
    float  *Lr;
    float  *L_q;
    float  *L_u;
    float  *polcor;
    float  *dpol;
    float  *tg_sol;
    float  *tg_sen;
    float  *t_sol;
    float  *t_sen;
    float  *t_o2;
    float  *t_h2o;

    float  *ws;
    float  *wd;
    float  *mw;
    float  *zw;
    float  *pr;
    float  *oz;
    float  *wv;
    float  *rh;
    float  *no2_tropo;
    float  *no2_strat;
    float  *no2_frac;
    float  *height;
    float  *glint_coef;
    float  *cloud_albedo;
    float  *aerindex;
    float  *sst;
    float  *sstref;
    float  *sssref;
    float  *sw_n;
    float  *sw_a;
    float  *sw_bb;
    float  *rhos;
    float  *rho_cirrus;

    int32_t   *iwave;
    float  *fwave;
    float  *Fo;
    float  *Fobar;
    float  *Fonom;
    float  *Tau_r;
    float  *k_oz;
    float  *aw;
    float  *bbw;

    float  *delphi;
    float  *csolz;
    float  *csenz;
    float  *alpha;
    float  *scattang;

    char   *mask;
    int32_t   *flags;

    int32_t   *pixdet;
    float  *radcor;
    float **in_prods;

    instr  *input;
    tgstr  *tgrec;

    float *Rrc;
    float *field_AOT;
    float *field_Lw;
    float *field_aer_modnum;
    int32_t *invalid;
    float *phase; // FELIXDU just for output
    float *gain;
    float *Lw_new; // just for output
    float *aot_new; // just for output
} l2str;

typedef struct {
    int32_t   type; // HY1C or MODIS
    int32_t   sensorID;
    int32_t   npix;
    int32_t   nscans;
    int32_t   *modis_matched_flag;
    int32_t   *side_flag;
    int32_t   *year;
    int32_t   *day;
    int32_t   *msec;
    float  *lon;
    float  *lat;
    float  *Fo;
    float  *Lr;
    float  *TLg;
    float  *tLf;
    float  *Lt;
    float  *Lt_theroy;
    float  *Lw;
    float  *taua;
    float  *tg_sol;
    float  *tg_sen;
    float  *t_sol;
    float  *t_sen;
    int32_t   *aermodmin;
    int32_t   *aermodmax;
    float  *aerratio;
    float  *eps;
    int32_t   *flags;
    float  *solz;
    float  *sola;
    float  *senz;
    float  *sena;
    float  *wv;
    float *field_AOT;
    float *field_Lw;
    float *field_AOT_lonlat;
    float *field_Lw_lonlat;
    float *field_aer_modnum;
    float *gain;
    float *Lw_new; // just for output
    float *aot_new; // just for output
    float  *delphi;
    float  *La;
    int32_t * invalid;
    char * begin_date;
    char * begin_time;

    float  *rh;
    float  *pr;
    float  *ws;
    float  *Tau_r;
}l2rec_HY1C;

#endif



